home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / C++ A'Link Files / 1990 / Aug 90 / CPlus.Dev$ 8⁄10⁄90 / 0169-operator== and opera-Aug90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.5 KB  |  43 lines  |  [TEXT/GEOL]

  1. Item    4258841                         9-Aug-90        14:58PDT
  2.  
  3. From:   MM.XOBJ                         MacroMind, Haim Zamir,PRT
  4.  
  5. To:     CPLUS.DEV$                      C++ Interest List--Developers
  6.         CPLUS.APPLE$                    C++ Interest List--Apple Employees
  7.  
  8. Sub:    operator== and operator!=
  9.  
  10. C++ folks:
  11.  
  12. I have defined an operator== for a type. I checked the C output to see what
  13. happens if I do a !=.  It turns out that the reverse of some default equality
  14. operator is used instead of the reverse of the operator== I provide.  OK, so I
  15. provide an explicit operator!= also.  The AT&T reference manual and Lippman,
  16. however, are mute on this subject.  (Except that the AT&T manual explicitly
  17. says that operator= (assignment) is the ONLY one that has a default operator
  18. created for it.  What gives?
  19.  
  20. What is worse, the construct
  21.  
  22.     if(type)
  23.         ...
  24.  
  25. will not yield the equivalent of  "if(type != 0)" and even with an operator!=,
  26. the expression "if(!type)" won;t yield the equivalent of "if(type == 0)"
  27.  
  28. I have resorted to doing these tests on types since the types are smart
  29. pointers (in reality complex structures) that I use to point to other types.
  30. It is important to reliably check them against null, and compare them against
  31. other types.  In other respects they really do feal like pointers.
  32.  
  33. Does anyone know of other limitations that I may not have caught for these
  34. particular overloads, or significant others related to pointers?
  35.  
  36.  
  37. Overloaded, I remain,
  38.  
  39. Haim Zamir
  40. MacroMind, Inc.
  41. AppleLink MM.XOBJ
  42.  
  43.